<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    //解构写法
    var a = 1;
    var b = 2;
    [a, b] = [b, a];
    console.log(a, b);
    //传统写法
    var a1 = 1;
    var b1 = 2;
    var temp = a1;
    a1 = b1;
    b1 = temp;
    console.log(a1, b1);
  </script>
</html>
